package logic

import (
	"context"

	"MBTI/rpc/login/internal/svc"
	"MBTI/rpc/login/log"

	"github.com/zeromicro/go-zero/core/logx"
)

type LoginLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
	return &LoginLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LoginLogic) Login(in *log.LoginReq) (*log.IsSuccessResp, error) {
	// todo: add your logic here and delete this line
	loginresp, err := l.svcCtx.StudentModel.Login(in.StudentNo, in.Password)
	if err != nil {
		return nil, err
	}
	return &log.IsSuccessResp{
		IsSuccess: loginresp,
	}, nil
}
